package javaCode.chapter09.codeblock_;

public class CodeBlockDetail04 {
    public static void main(String[] args) {
        //(1) 类的加载
        //1.1 先加载父类 A02     1.2 再加载 B02
        //(2) 创建对象
        //2.1 从子类构造器开始
        new B02();
    }
}

class A02 {
    private static int n1 = getVal01(); //1

    static {
        System.out.println("A02的静态代码块...");//2
    }

    {
        System.out.println("A02的普通代码块..."); //5
    }

    public int n3 = getVal02(); //6

    public static int getVal01() {
        System.out.println("getVal01");
        return 10;
    }

    public int getVal02() {
        System.out.println("getVal02");
        return 10;
    }

    public A02() { //7
        //隐藏
        //super()
        //普通代码块和普通属性的初始化...
        System.out.println("A2 的构造器");
    }
}

class B02 extends A02{
    private static int n3 = getVal03(); //3

    static {
        System.out.println("B02的静态代码块.."); //4
    }

    public int n5 = getVal04(); //8

    {
        System.out.println("B02的普通代码块.."); //9
    }

    public static int getVal03(){
        System.out.println("getVal03");
        return 10;
    }

    public int getVal04(){
        System.out.println("getVal04");
        return 10;
    }

    public B02() { //10
        //隐藏
        //super()
        //普通代码块和普通属性的初始化...
        System.out.println("B02的构造器");
    }
}

